package cn.javasea.rbac.shiro.controller;

import cn.javasea.rbac.shiro.service.SysUserLoginService;
import cn.javasea.rbac.shiro.util.LoginInfor;
import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 账号登录
 * @Author: xiangchao
 * @Date: 2023/2/1
 */
@RestController
public class SysUserLoginController {

    @Autowired
    private SysUserLoginService sysUserLoginService;

    /**
     * description: 登录
     * @return 登录结果
     */
    @PostMapping("/login")
    public JSONObject login(String userName, String password,
                            LoginInfor infor) {
        return sysUserLoginService.login(userName, password, infor);
    }

//    @RequiresPermissions("sss:ss")
    @GetMapping("/targetUrl")
    public String testApi(){
        System.out.println("授权成功====="+SecurityUtils.getSubject().getSession().getId());
        return "success";
    }

}
